<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>进制转换</title>
    <style>
        body{
               background-color: #4c4c4c;
        }
        #div1{
            width: 400px;
            height: 300px;
            background-color: #019e8b;
            color: #ab1212;
            margin: 0 auto;
        }
        #div2{
            padding-top: 30px;
        }
    </style>
</head>
<body>
   <div id="div1">
       <div id="div2">
       <span>请输入要转换的数字：</span>
       <input id="numbers" type="text">
       <button onclick="nuu()">转换</button><br>
       <p id="one"></p>
       <p id="two"></p>
       <p id="three"></p>
       <p id="four"></p>
       </div>
   </div>
<script>
    //1：首先先得到输入框中的数字；
    var number = document.getElementById("numbers");

    function nuu() {
        var num =Number(number.value);
        document.getElementById("one").innerHTML ="二进制为：  "+ (num.toString(2));
        document.getElementById("two").innerHTML ="八进制为：  "+ (num.toString(8));
        document.getElementById("three").innerHTML ="十进制为： "+ (num.toString(10));
        document.getElementById("four").innerHTML ="十六进制为："+ (num.toString(16));
    }
</script>
</body>
</html>